#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int year = 0;
	int mouse = 0;
	int day = 0;
	int sum = 0;
	scanf("%d %d %d", &year, &mouse, &day);
	int arr[20] = { 0,31,28,31,30,31,30,31,31,30,31,30,31};
	if ((year % 4 == 0 && year % 100 != 0 )|| year % 400 == 0)
	{
		arr[2] +=1;
	}
	for (int i = 0; i < mouse; i++)
	{
		sum += arr[i];
	}
	sum += day;
	printf("%d", sum);
	return 0;
}